package com.xsomnus.java_basic.juc.exceptions;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author @叶小夏
 * @since 2019/7/29 0029 17:26
 * - 才需学也,学需静也/非淡泊无以明志，非宁静无以致远
 */
public class SubThreadExceptionDemo2 {

    public static void main(String[] args) {
        ExecutorService es = Executors.newCachedThreadPool();
        final Future<String> future = es.submit(new SubThread());
        try {
            future.get();
        } catch (InterruptedException e) {
            System.out.println(String.format("handle exception in child thread. %s", e));
        } catch (ExecutionException e) {
            System.out.println(String.format("handl1e exception in child thread. %s", e));
        } finally {
            es.shutdown();
        }
    }
}
